package com.two.commodityorder.controller;
//更新商品
import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.two.commodityorder.service.CommodityService;
import com.two.commodityorder.service.impl.CommodityServiceImpl;

@WebServlet("/updateCommodityServlet.do")
public class UpdateCommodityServlet extends HttpServlet {



	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doPost(req, resp);
    }

    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        // 设置请求对象的编码格式
    	req.setCharacterEncoding("utf-8");
		resp.setCharacterEncoding("UTF-8");
        // 获取传入的商品名称和价格
		String id = req.getParameter("id");
        String commodityName = req.getParameter("commodityName");
        String price = req.getParameter("price");
        CommodityService service = new CommodityServiceImpl();
        boolean result = service.UpdateCommodity(id, commodityName, price);

        System.out.println("更新结果：" + result);
		req.getRequestDispatcher("view/productcontrol/chaxun.html").forward(req, resp);//网页地址
    }
}